import java.io.*;
import java.util.*;

public class FileUpdate1{
  public static void main(String[] args)throws IOException{
    // 1. Create a FileInputStream object
    FileInputStream instream = new FileInputStream("input.txt");
    
    // 2. Wrap the input stream in a scanner
    Scanner fscanner = new Scanner(instream);
    
    //3. Create an array
    int[] array = new int[5];
    
    // 4.  Initialize the array with the file contents
    for(int k = 0; k < array.length; k++)
      array[k] = fscanner.nextInt();
    
    // 5. Close the input stream
    fscanner.close();
    
     // 6. Update the array
     for(int k = 0; k < array.length; k++)
       array[k] += 2; 
     
     // 7. Create an associated output stream
     PrintWriter pwriter = new PrintWriter("input.txt");
     
     // 8. Overwrite the file with the values of the updated array
     for(int k = 0; k <= array.length - 2; k++)
       pwriter.println(array[k]); 
     
       pwriter.print(array[array.length - 1]);   // Write last element without generating new line
     
     // 9. Close the output stream
     pwriter.close();
     // 10. For convenience inform the user that the file has been updated
     System.out.println("The file input.txt has been updated . . .");
  }
}
     